<?php
declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/11
 * Time: 15:01
 */

namespace App\Model;

use Hyperf\Database\Model\Model;
use Hyperf\Database\Model\SoftDeletes;

class ActPrizeRule extends Model
{
    use SoftDeletes;
    protected ?string $table='act_prize_rule';
    public bool $timestamps = true;

    protected array $fillable = ['act_id','rule','percent','template'];

    public function getRuleAttribute($value): string
    {
        return $value != null ? htmlspecialchars_decode($value) : '';
    }

    public function setRuleAttribute($value): void
    {
        if($value!='') htmlspecialchars($value);
        $this->attributes['rule'] = $value;
    }

    public function prizeGoods(): \Hyperf\Database\Model\Relations\hasMany
    {
        return $this->hasMany(ActPrizeGoods::class, 'act_id', 'id');
    }

}